The keygen Element

The keygen element is a form element in HTML 5 which is used to generate a key pair to provide the security while authenticating the users. The keygen element acts as a key pair generator control. After the submission of the form, this element generates the private and public keys where a private key is used to store on a client side and a public key is bundled into a package and then sent to the server. You can generate a client certificate from the public key to authenticate the users in future.

Let’s do the following steps to create a list of options:


<!DOTYPE html>
<head>
    <title>Use of keygen</title>
</head>
<body>
<center>
    <h2>Example of generating key </h2>
    <form>
        <keygen name=”key”><br><br>
        <input type=”submit” value=”key-generated”>
    </form>
</center>
</body>
</html>

Save the document with the name Keygen.html and open on browser.

Note: After clicking, it will prompt a Password window to fill up the required details for the authentication purpose, if user is generating a key first time. Enter the passwords in the passwords fields and click the OK button.

After entering password then key is generated and provided on the address bar.